from machine import FPIOA
from machine import Pin
import time

fpioa = FPIOA()

fpioa.set_function(53, FPIOA.GPIO53)
fpioa.set_function(62, FPIOA.GPIO62)
fpioa.set_function(20, FPIOA.GPIO20)
fpioa.set_function(63, FPIOA.GPIO63)


button = Pin(53, Pin.IN, Pin.PULL_DOWN)

LED_R = Pin(62, Pin.OUT, pull=Pin.PULL_NONE, drive = 7)
LED_G = Pin(20, Pin.OUT, pull=Pin.PULL_NONE, drive = 7)
LED_B = Pin(63, Pin.OUT, pull=Pin.PULL_NONE, drive = 7)

LED_R.high()
LED_G.high()
LED_B.high()

LED = LED_B

debonce_delay = 20 #ms
led_on = False
last_button_state = 0

while True:
    button_state = button.value()
    if button_state == 1 and last_button_state == 0:
        time.sleep_ms(debonce_delay)
        button_state = button.value()
        if button_state == 1:
            if led_on:
                LED.high()
            else:
                LED.low()
            led_on = not led_on
            last_button_state = 1
    elif button_state == 0 and last_button_state == 1:
        last_button_state = 0

'''
while True:
    if button.value() == 1:
        LED.high()
    elif button.value() == 0:
        LED.low()
'''
